package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 学历枚举类
 * @Author: duyufu
 * @Date: 2019/4/24 13:12
 */
public enum EducationEnum {
//	EDUCATION_BX(0,"暂无"),
	EDUCATION_XX(1,"小学"),
	EDUCATION_CZ(2,"初中"),
	EDUCATION_ZZ(3,"中专"),
	EDUCATION_GZ(4,"高中"),
	EDUCATION_DZ(5,"大专"),
	EDUCATION_BK(6,"本科"),
	EDUCATION_SS(7,"硕士"),
	EDUCATION_BS(8,"博士");
	
	private Integer code;
	private String name;
	
	
	private EducationEnum(Integer code, String name){
		this.code=code;
		this.name=name;
	}
	
	//把枚举转成json
	 public static String getJsonString(){
	    	StringBuilder builder = new StringBuilder("{");
	    	for(EducationEnum educationEnum:EducationEnum.values()){
	    		builder.append("\""+educationEnum.getCode()+"\":\""+ educationEnum.getName()+"\",");
	    	}
	    	String json=builder.substring(0, builder.length()-1)+"}";
	    	return json;
	    } 
	 
	public static List getEducation(){
	    	List list = new ArrayList();
	    	Map<String,Object> map;
	    	for(EducationEnum educationEnum:EducationEnum.values()){
	    		map= new HashMap<String, Object>();
	    		map.put("code", educationEnum.getCode());
	    		map.put("name", educationEnum.getName());
	    		list.add(map);
	    	}
	    	return list;
	    } 
	  
	  public static String getNameByCode(Integer code){
		  for(EducationEnum educationEnum:EducationEnum.values()){
			  if(code.equals(educationEnum.getCode())){
				  return educationEnum.getName();
			  }
		  }
		  return null;
	  }

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
	

}
